from PIL import Image

def image_to_pixel_stream(image_path):
    image = Image.open(image_path)
    pixel_stream = image.tobytes()
    binary_string = ''.join(format(byte, '08b') for byte in pixel_stream)
    return binary_string

# 调用函数将图像转换为像素流
image_path = 'original_image/1.png'
pixel_stream = image_to_pixel_stream(image_path)

binary_string = ''.join(format(byte, '08b') for byte in pixel_stream)
byte_value = bytes(int(binary_string[i:i+8], 2) for i in range(0, len(binary_string), 8))
# print(binary_string)
# print(pixel_stream)
# print(binary_string)
print("/n")
# print(byte_value)
